# -*- encoding:utf-8 -*-
from .base_model import BaseModel

class Menu(BaseModel):
    cols = {"url": {"name": "菜单URL", "type": "string"}, "name": {"name": "名称", "type": "string"}}
    model_name = "菜单"

    def find_by_role(self, id):
        role = self.db.get_one('SELECT * FROM `role` WHERE id = %s' % (id))
        return self.db.get_all('SELECT * FROM `menu` WHERE id IN (%s)' % (role['menu_ids']))
